package com.niiwoo.civet.account.service.dubbo;


import com.alibaba.dubbo.config.annotation.Service;
import com.niiwoo.civet.account.dao.entity.PayChannel;
import com.niiwoo.civet.account.dao.mapper.PayChannelMapperExt;
import com.niiwoo.civet.account.dto.request.PayChannelRequestDTO;
import com.niiwoo.civet.account.dto.response.PayChannelResponseDTO;
import com.niiwoo.civet.account.enums.OrderEnum;
import com.niiwoo.civet.account.enums.PayChannelTypeEnum;
import com.niiwoo.civet.account.service.PayChannelDubboService;
import lombok.extern.slf4j.Slf4j;
import org.springframework.beans.BeanUtils;
import org.springframework.beans.factory.annotation.Autowired;

import java.util.ArrayList;
import java.util.List;

@Slf4j
@Service(version = "1.0.0")
public class PayChannelDubboServiceImpl implements PayChannelDubboService {

    @Autowired
    private PayChannelMapperExt payChannelMapperExt;


    @Override
    public List<PayChannelResponseDTO> getRechargePayChannel(PayChannelRequestDTO payChannelRequestDTO) {
        List<PayChannel> payChannelList = payChannelMapperExt.selectPayChannelByType(payChannelRequestDTO.getPayChannelTypeEnum().name(), payChannelRequestDTO.getStatus(), payChannelRequestDTO.getOrderEnum().name());
        if( null != payChannelList ){
            List<PayChannelResponseDTO> payChannelResponseDTOS = new ArrayList<>();
            for(PayChannel payChannel:payChannelList){
                PayChannelResponseDTO dto = new PayChannelResponseDTO();
                BeanUtils.copyProperties(payChannel,dto);
                payChannelResponseDTOS.add(dto);
            }
            return  payChannelResponseDTOS;
        }
        return null;
    }
}
